<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EmpleadoDB
 *
 * @author Admin
 */
class EmpleadoDB extends CI_Model {

    var $title = '';
    var $content = '';
    var $date = '';

    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }

    function get_last_ten_entries() {
        $query = $this->db->get('empleado', 10);
        return $query->result();
    }

    function Insert_Table($arrData) {


        if (!empty($arrData["f_egr"]))
            $this->db->insert('empleado', $arrData);
        else {
            $arrData["f_egr"] = NULL;
            $this->db->insert('empleado', $arrData);
        }
    }

    function Insert_Table_Cargo($arrData) {


        if (!empty($arrData["f_fin"]))
            $this->db->insert('dxcxe', $arrData);
        else {
            $arrData["f_fin"] = NULL;
            $this->db->insert('dxcxe', $arrData);
        }
    }

    function Insert_Table_Telf($arrData) {

        $this->db->insert('exnt', $arrData);
    }

    function Insert_Table_Email($arrData) {

        $this->db->insert('exce', $arrData);
    }

    function Delete_Table($item) {
        /* $this->db->where('ficha', $item['eliminar']);
          $this->db->delete('empleado'); */


        $q = $this->db->get_where('empleado', array('ficha' => $item['eliminar']));
        if ($q->result()) {
            $this->db->where('ficha', $item['eliminar']);
            $this->db->delete('empleado');
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function update_entry($arrData) {

        /*if ($this->cod = $arrData["ficha"])
            ;
        $this->content = $_POST['content'];
        $this->date = time();

        $this->db->update('entries', $this, array('id' => $_POST['id']));*/

        $this->db->where('ficha', $arrData['ficha']);
        $q = $this->db->get('empleado');

        if ($q->num_rows() > 0) {
            $this->db->where('ficha', $arrData['ficha']);
            $this->db->update('empleado', $arrData);
            return TRUE;
        }else FALSE;
    }

}
